import { ItemData } from "./ItemData";
import { Cache } from "../../cache/Cache";
type int = number;
//class DailyCompRewardInfo
    
    export  class DailyCompRewardInfo
    {
        constructor()
        {
            
            this._itemRewardResults = [];
            this._itemRewards = [];
            this._expAndGoldRewards = [];
            return;
        }

        public updateReward(arg1: string): void
        {
            var loc2=0;
            var loc4=null;
            var loc5=null;
            this._expAndGoldRewards.splice(0);
            var loc1=arg1.split("#");
            var loc3=loc1.length;
            while (loc2 < loc3) 
            {
                loc5 = (loc4 = loc1[loc2]).split(",");
                this._expAndGoldRewards.push(loc5);
                ++loc2;
            }
            return;
        }

        public updateItem(arg1: string): void
        {
            var loc2=0;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            this._itemRewards.splice(0);
            var loc1=arg1.split("#");
            var loc3=loc1.length;
            while (loc2 < loc3) 
            {
                loc5 = (loc4 = loc1[loc2]).split(",");
                loc6 = new ItemData(int(loc5[1]));
                loc5[1] = loc6;
                this._itemRewards.push(loc5);
                ++loc2;
            }
            return;
        }

        public getRewardByLevel(arg1: int=-1): Array<any>
        {
            var loc1=0;
            var loc3=null;
            var loc4=null;
            var loc5=0;
            var loc6=0;
            if (arg1 == -1) 
            {
                arg1 = Cache.instance.role.entityInfo.level;
            }
            var loc2=this._expAndGoldRewards.length;
            while (loc1 < loc2) 
            {
                loc3 = this._expAndGoldRewards[loc1];
                if (loc1 == (loc2 - 1)) 
                {
                    loc6 = 0;
                }
                else 
                {
                    loc6 = (loc4 = this._expAndGoldRewards[loc1 + 1])[0];
                }
                loc5 = loc3[0];
                if (loc6 == 0) 
                {
                    return loc3;
                }
                if (arg1 >= loc5 && arg1 < loc6) 
                {
                    return loc3;
                }
                if (arg1 < loc5) 
                {
                    return loc3;
                }
                ++loc1;
            }
            return null;
        }

        public get itemRewards(): Array<any>
        {
            var loc2=0;
            var loc4=null;
            var loc5=null;
            var loc6=0;
            var loc1=Cache.instance.role.entityInfo.level;
            if (loc1 == this._lastLevel) 
            {
                return this._itemRewardResults;
            }
            this._lastLevel = loc1;
            this._itemRewardResults.splice(0);
            var loc3=this._itemRewards.length;
            var loc7=-1;
            while (loc2 < loc3) 
            {
                loc6 = (loc4 = this._itemRewards[loc2])[0];
                if (loc1 < loc6) 
                {
                    if (loc2 != 0) 
                    {
                        loc7 = (loc5 = this._itemRewards[(loc2 - 1)])[0];
                    }
                    else 
                    {
                        loc7 = loc6;
                    }
                    break;
                }
                ++loc2;
            }
            if (loc7 == -1 && loc3 > 0) 
            {
                loc7 = this._itemRewards[(loc3 - 1)][0];
            }
            loc2 = 0;
            loc3 = this._itemRewards.length;
            while (loc2 < loc3) 
            {
                if ((loc6 = (loc4 = this._itemRewards[loc2])[0]) == loc7) 
                {
                    this._itemRewardResults.push(loc4);
                }
                ++loc2;
            }
            return this._itemRewardResults;
        }

        public /* var */index: int;

        /* internal */ /* var */_itemRewards: Array<any>;

        /* internal */ /* var */_expAndGoldRewards: Array<any>;

        /* internal */ /* var */_lastLevel: int;

        /* internal */ /* var */_itemRewardResults: Array<any>;
    }
